#include "Sequeue.h"



//**************************循环队列建立*************************//




int Sequeue_init(Sequeue *s){  //初始化队列
	unsigned char i=0;
	for(i=0;i<=SequeueSize-1;i++)
		s->data[i] = 0;
	s->S_front = s->S_rear = SequeueSize-1;
	s->num = 0;
	return 1;
}

int Sequeue_In(Sequeue *s, DataType x){   //入队
	if(s->num == SequeueSize - 1) return 0; //对满
	s->S_rear = (s->S_rear + 1) % SequeueSize;
	s->data[s->S_rear] = x;
	s->num ++;
	return 1;
}


int Sequeue_Out(Sequeue *s, DataType *x){  //出对
	if(s->num == 0) return 0;
	s->S_front = (s->S_front + 1) % SequeueSize;
	*x = s->data[s->S_front];
	s->data[s->S_front] = 0;
	s->num --;
	return 1;
}

DataType Sequeue_front(Sequeue *s){
	if(s->num == 0) return 0;
	return s->data[(s->S_front + 1) % SequeueSize];
}



























